package com.yifeng.repo.endpoint.security.context.manager;

import com.yifeng.repo.endpoint.security.console.api.dto.AccountDto;
import com.yifeng.repo.endpoint.security.console.api.dto.AccountPermissionDto;

/**
 * Created by daibing on 2023/8/23.
 */
public class RequestContextManager {
    private static final ThreadLocal<AccountDto> CTX_ACCOUNT = new ThreadLocal<>();
    private static final ThreadLocal<AccountPermissionDto> CTX_PERMISSION = new ThreadLocal<>();

    public static AccountDto getAccount() {
        return CTX_ACCOUNT.get();
    }

    public static void setAccount(AccountDto value) {
        CTX_ACCOUNT.set(value);
    }

    public static AccountPermissionDto getPermission() {
        return CTX_PERMISSION.get();
    }

    public static void setPermission(AccountPermissionDto value) {
        CTX_PERMISSION.set(value);
    }

    public static void clear() {
        CTX_ACCOUNT.remove();
        CTX_PERMISSION.remove();
    }
}
